package zy.data.food.util;

import zy.data.food.enums.CodeEnum;

/**
 * @Auther: zhangy
 * @Date: 2018/9/11 12:05
 * @Description:
 */
public class EnumUtil {

    public static <T extends CodeEnum> T getByCode(Integer code,Class<T> enumClass){

        for(T each: enumClass.getEnumConstants()){

            if(code.equals(each.getCode())){
                return each;
            }

        }
        return null;
    }

}
